<?php

class View {

	protected $layout;
	protected $viewPath;
	protected $data = array();

	public function __construct($controller, $action, $data) {
		if(!empty($action)) {
			$this->viewPath = ROOT . DS . 'application' . DS . 'view' . DS . $controller . DS . $action . '.php';
			$this->data = $data;
			if($action=='login') {
				$this->layout = LAYOUT_LOGIN;
			} elseif(strpos($action, 'Ajax') === FALSE) {
				$this->layout = LAYOUT;
			} else {
				$this->layout = null;
			}
		}	
	}

	public function render() {
		if(!empty($this->viewPath)) {
			if ($this->layout === null) {
				require($this->viewPath);
			} else {
				$content = ($this->viewPath);
				require $this->layout;
			}
		}
			
	}

}